// 作为内容脚本和弹出页面之间的中介
chrome.runtime.onConnect.addListener((port) => {
    port.onMessage.addListener((msg) => {
        if (msg.action === 'getTextPositions') {
            chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => {
                chrome.tabs.sendMessage(
                    tabs[0].id,
                    { action: 'getTextPositions' },
                    (response) => {
                        port.postMessage(response);
                    }
                );
            });
        }
    });
});